.\" Copyright (C) 2014 Shang-Rong Cai. All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $ DIDF: did_body.3    Rev. 0.1.2    2014-09-18T19:23+08:00 $
.TH DID_BODY 3 2014-09-18 "DIDF 0.1" "Duplex Index Data File Manual"
.SH NAME
\fBdid_body_t\fP, \fBdid_body_create\fP, \fBdid_body_delete\fP - body part of
duplex index data file
.SH SYNOPSIS
\fB#include <did.h>\fP

\fIdid_body_t bdprt;\fP

\fIint\fP
.br
\fBdid_body_create\fP(\fIdid_body_t\fP \fI*bdprt\fP,
\fIconst\fP \fIdid_head_t\fP \fI*hdprt\fP,
.br
    \fIconst\fP \fIdid_meta_t\fP \fI*mtprt\fP,
\fIconst\fP \fIvoid\fP \fI*fst_idx_lst\fP,
.br
    \fIconst\fP \fIvoid\fP \fI*snd_idx_lst\fP,
\fIconst\fP \fIvoid\fP \fI*dat_ent_lst\fP);

\fIint\fP
.br
\fBdid_body_delete\fP(\fIdid_body_t\fP \fI*bdprt\fP);

.SH DESCRIPTION
The function \fBdid_body_create\fP() is to create a \fBdid_body_t\fP structure
to the data of duplex index data file, and also allocates proper size of
memory to use.  The indices, data values, and the internal structure will be
set or create by this function.  On the other hand, the function
\fBdid_body_delete\fP() is used the destory the structure and releasing memory
which allocated.  The parameters of basic functions for \fBdid_body_t\fP data
structure:

\fBmtprt\fP
The data structure objects.
.TP
\fBhdprt\fP
The corresponding head part by \fBdid_head_t\fP.
.TP
\fBmdprt\fP
The corresponding meta part by \fBdid_meta_t\fP.
.TP
\fBfst_idx_lst\fP
The input array of first indices.  The index type should be the same setting as
in the hdprt.
.TP
\fBsnd_idx_lst\fP
The input array of second indices.  The index type should be the same setting
as in the hdprt.
.TP
\fBdat_ent_lst\fP
The input array of data entries.  The entry type should be the same setting as
in the hdprt.

.LP
The return value is the error number.

The data structure \fBdid_body_t\fP is define as the following.

.nf
typedef struct
{
    void *fst_dst;  /* Distribution of indexed data depended on first index */
    void *ide_lst;  /* Indexed data entry list */

    void *snd_dst;  /* Distribution of index and offset depended on second index */
    void *iao_lst;  /* Index and offset list */
} did_body_t;

.fi

The variable \fBfst_dst\fP is the address of allocated memory which has size of
amount of data entries plus one blocks, where the size of blocks is depended on
the index type.  It is the start and end (before the value) address (in the
unit of blocks depended on index type and entry type) for list of data entries.
The variable \fBide_lst\fP is the data entry combined second index and data
value.  The variable \fBsnd_dst\fP is similar the before one for index and
offset list (the variable \fBiao_lst\fP).  The block size of index and offset
list is only depended on the index type.  Users should not be handling these
variables directly to avoid the crash.

.SH SEE ALSO
did_head_t(3), did_meta_t(3)
